import { defineStore } from "pinia";
import i18n from "../view/lang";
const useUserStore = defineStore("lang",{
    state:()=>({
       lang:"zh",
    }),
    // 方法：同步和异步
    actions: {
    changeLang(val){
        i18n.global.locale.value= val;
        this.lang= val;
}
    },
    // 计算属性
    getters: { },
    persist:{
        enabled:true,
        strategies:[
            {
                key :"lang",
                storage:localStorage,
            }
        ]
    }
});
export default useUserStore;
